package worst.shopping.lists;

import java.util.HashMap;
import java.util.Map;

import database.DataBaseKeys;

import worst.shopping.R;
import android.database.Cursor;
import android.view.View;
import android.widget.TextView;
import android.widget.SimpleCursorAdapter;

public class MyViewBinder implements SimpleCursorAdapter.ViewBinder {

	public Map< String, String > selectedCount = new HashMap<String, String>();
	
	public boolean setViewValue(View view, Cursor cursor, int colindex) {

		if(view.getId() != R.id.list_item_count)
			return false;
		else{
			cursor.moveToPosition(colindex);
			String count = selectedCount.get(cursor.getString(cursor.getColumnIndex(DataBaseKeys.PRODUCT_NAME)));
			
			TextView textview = (TextView)view;
			if(count != null)
				textview.setText(count);
			else
				textview.setText("");
			return true;
		}
	}

}
